package com.eveinfo.notification;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;

import com.eveinfo.EveInfo;
import com.eveinfo.R;

public class AlarmReceiver extends BroadcastReceiver {
	@Override
	public void onReceive(Context context, Intent intent) {
		System.out.println("onReceive");

		int notificationID = intent.getIntExtra("notification", 0);
		
		NotificationManager manger = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
		Notification notification = new Notification(R.drawable.eveinfo, "Wake up alarm", System.currentTimeMillis());
		PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(context, EveInfo.class), 0);
		notification.setLatestEventInfo(context, "Context Title " + notificationID, "Context text", contentIntent);
		notification.flags = Notification.FLAG_INSISTENT;

		notification.sound = (Uri) intent.getParcelableExtra("Ringtone");
		notification.vibrate = (long[]) intent.getExtras().get("vibrationPatern");
		manger.notify(notificationID, notification);
	}
}
